package com.neuedu.javase.gui;

import javax.swing.*;
import java.awt.*;

/**
 * @auth 金山老师
 * title:   书籍代码
 * creatime: 2022-10-06 11:30
 * 描述 :
 */
public class MyFrame extends JFrame  {

    private String name;
    private int age;



    public MyFrame() throws HeadlessException {
        this.setTitle("demo GUI");
        this.setLocation(100,100);
        this.setSize(500,300);

        //改变默认的 x的行为  --->  退出虚拟机
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        //初始化一下组件
        initComponents();

        this.setVisible(true);
    }

    private void initComponents() {
        //        BorderLayout layout = this.getLayout();

//        Button btn1 = new Button("Center TestButton");
//        this.add(btn1, BorderLayout.NORTH);
        this.add(new Button("North"), BorderLayout.NORTH);
        this.add(new Button("South"), BorderLayout.SOUTH);
        this.add(new Button("West"), BorderLayout.WEST);
        this.add(new Button("east"), BorderLayout.EAST);
        JPanel jPanel = new MyPanel();
        jPanel.setBackground(Color.BLUE);
        this.add(jPanel);


    }

    public static void main(String[] args) {
//        new MyFrame();

        String s1 = new String ("amit") ;

        System. out. println(s1. replace('m','r')) ;

        System. out.println(s1) ;

        String s3 = "arit";

        String s4 = "arit";

        String s2 = s1. replace('m', 'r') ;

        System. out.println(s2 == s3) ;  //flase

        System. out.println(s3 == s4);




    }
}
